package com.simplehc7878.warning.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

@Getter
public enum RuleType {


    CON(1, "能耗异常"),
    CON_S(2, "单箱能耗异常"),
    CON_Z(3, "综合能耗异常");

    private final Integer value;
    private final String desc;

    RuleType(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static RuleType getByValue(Integer value) {
        Optional<RuleType> first = Arrays.stream(
                values()).filter(v -> Objects.equals(v.getValue(), value)).findFirst();
        if (first.isPresent()) {
            return first.get();
        }
        throw new RuntimeException("RuleType error");
    }
}
